<?php
namespace App\Http\Controllers\Web;

use App\Http\Controllers\Web\BaseController;
use Illuminate\Http\Request;


class NewsController extends BaseController
{
    protected  $api_url = [
        'index' => ['get', 'article/index_list'],
        'show' => ['get', 'article/%d'],
        'typeindex' => ['get', 'welcome'],
        'showArticleList' => ['get', 'welcome'],
    ];


    protected $request;

    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    /**
     * news 分类列表 获取 E井快讯 安防资讯列表
     * */
    public function index(){

        $page = $this->request->get('page',1);
        $search_params['fid'] = [27,28];
        $params = [
            'search' => search_params($search_params),
            'searchJoin' => 'and',
            'page' => $page,
            'orderBy' => 'updated_at',
            'sortedBy' => 'desc',
        ];
        $ret = http_web($this->api_url['index'])->send($params);

        $data = paginate($this->request, $ret['data']);
        $type_ret = http_web($this->api_url['typeindex'])->send();
        $data['info'] = $type_ret['data'];
//        dd($data);
        return view('web.news.newslist')->with($data);
    }
    /**
     * 分类详细文章列表
     * */
    public function show($id){
        var_dump($id);
        $ret = http_web($this->api_url['showArticleList'],[$id])->send();
        dd('前台分类列表');
    }
    
    public function infoAction($id){

      $ret = http_web($this->api_url['show'],[$id])->send();
      $type_ret = http_web($this->api_url['typeindex'])->send();
      //var_dump($ret['data']['updown']);exit;
      return view('web.news.news')->with(['info'=>$type_ret['data'],'new_info'=>$ret['data']]);
    }


}